Imports BikiSoft.Comm.Comm_Frame
Friend Class Comm_Exceptions
    Inherits Exception

    Private m_ErrNum As BikiFrameResponse
    Private m_ErrType As BikiFrameType
    Private m_ErrDesc As String = ""
    Private m_Throw As Boolean = False

    Sub New(ByVal ErrNum As BikiFrameResponse)
        m_ErrNum = ErrNum
        Select Case (m_ErrNum)
            Case BikiFrameResponse.CMD_OK
                m_ErrDesc = "Command OK"
            Case BikiFrameResponse.CMD_FAILED
                m_ErrDesc = "Command Failed"
                Throw Me
            Case BikiFrameResponse.CMD_CRC_FAILED
                m_ErrDesc = "CRC Failed"
                Throw Me
            Case BikiFrameResponse.CMD_NEXT
                m_ErrDesc = "Command Next"
            Case BikiFrameResponse.CMD_BAD_HEADS
                m_ErrDesc = "Command Failed, Malformed. Update firmware"
                Throw Me
            Case BikiFrameResponse.CMD_INCOMPLETE
                m_ErrDesc = "Command Failed, Incomplete. Update firmware"
                Throw Me
            Case BikiFrameResponse.CMD_TIMEOUT
                m_ErrDesc = "Command Timed out"
                Throw Me
            Case BikiFrameResponse.CMD_UNKNOWN
                m_ErrDesc = "Command Unknown, Update firmware"
                Throw Me
            Case BikiFrameResponse.CMD_UNKNOWN_RECIVER
                m_ErrDesc = "Command Unknown Reciver, Update firmware"
                Throw Me
            Case BikiFrameResponse.CMD_UNKNOWN_SENDER
                m_ErrDesc = "Command Unknown Sender, Update firmware"
                Throw Me
            Case BikiFrameResponse.FLASH_WRITE_TIMEOUT
                m_ErrDesc = "Flash Write Timeout, try again"
                Throw Me
            Case BikiFrameResponse.SEC_BAD_CODE
                m_ErrDesc = "Bad Security Code, try again"
                Throw Me
            Case BikiFrameResponse.SEC_FUNCTION_LOCKED
                m_ErrDesc = "Function Locked, unlock via password and try again"
                Throw Me
            Case Else
                m_ErrDesc = "Unknown Error code, Update Bikisoft"
                Throw Me
        End Select
    End Sub

    Public Property Description() As String
        Get
            Return m_ErrDesc
        End Get
        Set(ByVal value As String)
            m_ErrDesc = value
        End Set
    End Property

    Public Property Response() As BikiFrameResponse
        Get
            Return m_ErrNum
        End Get
        Set(ByVal value As BikiFrameResponse)
            m_ErrNum = value
        End Set
    End Property
End Class

Friend Class USB_exceptions

End Class
